pkg_name=util-linux
version=2.26
build_dir=$builds_dir_root/$pkg_name-$version
src_dir=$src_dir_root/$pkg_name-$version
url=https://www.kernel.org/pub/linux/utils/$pkg_name/v2.26/$pkg_name-$version.tar.xz

cd "$src_dir_root"
rm -Rf "$pkg_name-$version"
tar Jxf "$pkg_name-$version.tar.xz"

rm -Rf "$build_dir"
mkdir -p "$build_dir"
cd "$build_dir"

#weird stuff for directory configuration: some still goes in /sbin
#we miss some stuff like blkid, coze once --disable-all-programs is given to
#configure some brain damaged autoconf macro will not allow us to enable it by
#cherry picking it from the configure options.
export CFLAGS=-O0
"$src_dir/configure"			\
	--prefix=/			\
	--libdir=/lib64			\
	--sbindir=/bin			\
	--disable-nls			\
	--disable-static		\
	--disable-use-tty-group		\
	--disable-makeinstall-setuid	\
	--disable-makeinstall-chown	\
	--disable-bash-completion	\
	--with-gnu-ld			\
	--without-udev			\
	--without-python		\
	--without-systemd		\
	--without-selinux		\
	--disable-all-programs		\
	--enable-libuuid		\
	--enable-libblkid		\
	--enable-libmount		\
	--enable-libsmartcols		\
	--enable-mount			\
	--enable-losetup		\
	--enable-fsck			\
	--enable-partx			\
	--enable-mountpoint		\
	--enable-fallocate		\
	--enable-unshare		\
	--enable-nsenter		\
	--enable-eject			\
	--enable-cramfs			\
	--enable-hwclock		\
	--enable-wdctl			\
	--enable-switch_root		\
	--enable-pivot_root		\
	--enable-kill			\
	--enable-last			\
	--enable-raw			\
	--enable-rename			\
	--enable-reset			\
	--enable-vipw			\
	--enable-newgrp			\
	--enable-ul			\
	--enable-setterm		\
	--enable-schedutils
	
unset CFLAGS

make

install_tmp_dir=/tmp/$pkg_name-$version
rm -Rf "$install_tmp_dir"
mkdir -p "$install_tmp_dir"
make install "DESTDIR=$install_tmp_dir"

#fix installation
mv "$install_tmp_dir/sbin/addpart" "$install_tmp_dir/bin" 
mv "$install_tmp_dir/sbin/delpart" "$install_tmp_dir/bin" 
mv "$install_tmp_dir/sbin/partx" "$install_tmp_dir/bin" 
mv "$install_tmp_dir/sbin/resizepart" "$install_tmp_dir/bin" 
mv "$install_tmp_dir/sbin/vigr" "$install_tmp_dir/bin" 
mv "$install_tmp_dir/sbin/vipw" "$install_tmp_dir/bin" 

install_dirs "$builders_dir_root/$pkg_name/runtime.dirs"
install_files "$builders_dir_root/$pkg_name/runtime.files" "$install_tmp_dir"
install_links "$builders_dir_root/$pkg_name/runtime.links"
install_dirs "$builders_dir_root/$pkg_name/devel.dirs"
install_files "$builders_dir_root/$pkg_name/devel.files" "$install_tmp_dir"
install_links "$builders_dir_root/$pkg_name/devel.links"
elf_strip "$builders_dir_root/$pkg_name/elf-strip"

rm -Rf "$install_tmp_dir"
rm -Rf "$build_dir"
rm -Rf "$src_dir"
